﻿using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace SelfHosting.Handlers.Compression
{
    /// <summary>
    /// Compresseur Deflate
    /// </summary>
    public class DeflateCompressor : Compressor
    {
        /// <summary>
        /// Obtient le codate Deflate
        /// </summary>
        private const string DeflateEncoding = "deflate";

        /// <summary>
        /// Obtient le codate Deflate
        /// </summary>
        public override string EncodingType
        {
            get { return DeflateEncoding; }
        }

        /// <summary>
        /// Création du stream compressé
        /// </summary>
        /// <param name="output">Le stream à compresser</param>
        /// <returns>Le stream compressé</returns>
        public override Stream CreateCompressionStream(Stream output)
        {
            return new DeflateStream(output, CompressionMode.Compress, true);
        }

        /// <summary>
        /// Création du steam décompressé
        /// </summary>
        /// <param name="input">Stream à décompresser</param>
        /// <returns>Le stream décompressé</returns>
        public override Stream CreateDecompressionStream(Stream input)
        {
            return new DeflateStream(input, CompressionMode.Decompress, true);
        }
    }
}
